<!DOCTYPE html>
<html  xmlns:th="http://www.thymeleaf.org" lang="en">
<head>
    <meta charset="UTF-8">
    <title>注册</title>
    <script src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.8.0.js"></script>
</head>
<body>
<div>
    手机号：<input type="text" id="mobile" value="15316135973"/>
</div>
<div>
    密码：  <input type="text" id="password" value="abc123321#"/>
</div>
<div>
    学号：  <input type="text" id="number" value="2101210001"/>
</div>
<div>
    姓名：  <input type="text" id="name" value="李磊"/>
</div>
<div>
    性别：  <select id="gender">
    <option value="0">男</option>
    <option value="1">女</option>
</select>
</div>
<div>
    邮箱：  <input type="text" id="email" value="2575750214@qq.com"/>
</div>
<div>
    <button id="btn1">注册</button>
</div>
<div id="result">

</div>

</body>

<script type="text/javascript">
    $(document).ready(function () {
        $("#btn1").click(function () {
            var mobile = $("#mobile").val();
            var password = $("#password").val();
            var number = $("#number").val();
            var name = $("#name").val();
            var gender = $("#gender").val();
            var email = $("#email").val();

            $.ajax({
                type: 'post',
                //todo: 注册接口修改
                url: 'http://localhost:8088/register',
                contentType: 'application/x-www-form-urlencoded; charset=UTF-8',
                dataType: 'text json',
                data: {
                    mobile: mobile,
                    password: password,
                    number: number,
                    name: name,
                    gender: gender,
                    email: email
                },
                success: function (data) {
                    console.log(data)
                    if(data.status === 1){
                        alert("注册成功")
                        //todo: 重定向到登录界面进行登录
                        //window.location.href = "login.html"
                    }else{
                        alert(data.msg)
                        //$("#result").text("用户名或密码不符合格式要求！")
                    }
                },
                error: function (data) {
                    alert("参数错误")

                    //$("#result").text('参数错误！')
                }
            })

        })

    })
</script>

</html>